#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
	return x*f;
}
int k,m,n,l[N],r[N],x[N];
string s;
signed main(){
	freopen("copy.in","r",stdin);
	freopen("copy.out","w",stdout);
	k=read(),m=read();
	cin>>s,s=' '+s;
	n=read();
	for(int i=1;i<=n;++i) l[i]=read(),r[i]=read(),x[i]=read();
	for(int i=1;i<=k;++i){
		int u=i;
		for(int j=n;j;--j){
			int L=l[j]+1,R=r[j],PL=x[j]+1,PR=x[j]+1+(R-L);
			if(u>=PL&&u<=PR){
				int fst=u-PL;
				u=L+fst;
			}
			else if(u>PR) u-=(PR-PL+1);
		}
		cout<<s[u];
	}
	return 0;
}